<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<meta name="viewport"	content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=yes;" />

<script src="../com.atilax.frmwk/jquery-1.11.3.js"></script>
 <script type="text/javascript" src="rum.js"></script>
 
 <script type="text/javascript" src="../com.attilax/core/core.js"></script>
  <script type="text/javascript" src="../com.attilax\jsbridge\dsl_jsb_v12qaf.js"></script>
    <script type="text/javascript" src="../com.attilax\cfg\approot_jsV4q329.jsp"></script>
<script >
 hre_web_url="/DslAjaxJsbridgeServletV2";

</script>
<link rel="stylesheet" type="text/css" href="../com.atilax.frmwk/bootstrap-3.3.0-dist/dist/css/bootstrap.css">
<style> 
.ini
{
width:200px;
height:50px;
 
transition:width 2s;
-moz-transition:width 2s; /* Firefox 4 */
-webkit-transition:width 2s; /* Safari and Chrome */
-o-transition:width 2s; /* Opera */
}

.big
{
/*width:400px;*/
}
.big2
{
/*width:420px;*/
}
</style>

 
</head>



<body>

<div style=" padding-top:7px;  ">
<button type="button" class="btn btn-primary btn-lg ini" style="font-size: 30px" id="u_btn">
  <span class="glyphicon glyphicon-user"></span> User用户:<span id="u">0</span>
</button>
<p><p>
<button type="button" class="btn btn-success btn-lg ini  " style="font-size: 30px" id="r_btn">
  <span class="glyphicon glyphicon-tree-deciduous"></span> room房间:<span id="r">0</span>
</button>
<button type="button" class="btn btn-danger    " style="font-size: 30px" id="r">
  <span class="glyphicon glyphicon-star"></span> score:<span id="sko">0</span>
</button>
 

</div>

  <audio  id="bgmzk"  src="comin.wav" autoplay preload="auto"  loop="loop"     ></audio>
    <audio id="audio1" src="av/click.wav" preload="preload"  ></audio>  
<!--glyphicon glyphicon-tree-deciduous-->

<script>
function finish()
{
			window.setTimeout(function()
			{
				console.log("--add cls");
				$("#u_btn").addClass("big").css("width",$(window).width()-7); 
				
			},500);
			window.setTimeout(function()
			{
				console.log("--add cls2");
				 $("#r_btn").addClass("big2").css("width",$(window).width());
				
			},1000);
			
			
			 $("#bgmzk")[0].play();
			  document.addEventListener('touchstart', function(){ 
							 $("#bgmzk")[0].play(); 
						 
					}, false);
		
		
		
}
window.onload=finish;//不要括号
$(document).ready(function(){
//alert($(window).height()); //浏览器当前窗口可视区域高度
//alert($(document).height()); //浏览器当前窗口文档的高度
//alert($(document.body).height());//浏览器当前窗口文档body的高度
//alert($(document.body).outerHeight(true));//浏览器当前窗口文档body的总高度 包括border padding margin

//alert($(window).width()); //浏览器当前窗口可视区域宽度
//alert($(document).width());//浏览器当前窗口文档对象宽度
//alert($(document.body).width());//浏览器当前窗口文档body的宽度
//alert($(document.body).outerWidth(true));//浏览器当前窗口文档body的总宽度 包括border padding margin

});
//获取范围内的随机数
function randNum(minnum , maxnum){
    return Math.floor(minnum + Math.random() * (maxnum - minnum));
}
//例如，生成0-9的随机数(包括0和9)randNum(0,10)


  var PlayLayer={   //main layer,,one scence must hav a scence
	   curCyarIdx:-1,
	   cyararr:[5,20,50,100],
	   schedule:function(fun,interTime,repeat,delay){
		   window.setInterval(fun.bind(this),interTime*1000);
	   },
	    ctor:function () {
			
			 this.addSushi();
			 
			  this.schedule(this.addSushi,2,16*1024,1);
			
			},
			expFun: function(spr)
			{
			 	var tp=$(spr).offset().top; 
				var left=$(spr).offset().left;
					var imgStr='<img src="img/exp.gif" style="position:absolute; left:@lf@px; top:@t@px;width:100px;height:100px;"  class="sushi_tag_5kwi" />';
					imgStr=imgStr.replace("@lf@",left);
					imgStr=imgStr.replace("@t@",tp);
				 var $img=$(imgStr); 
				 $("body").append($img);
				 
				 //gc
							window.setTimeout(function(){
								 $img.remove();
								$(spr).remove();
								$("#sko").text(1+ parseInt($("#sko").text()));
							},700); 
									
			},
	  addSushi : function() {
		  				//alert(this.curCyarIdx);
		  
		  				this.curCyarIdx++;
						if(this.curCyarIdx>3)
							this.curCyarIdx=0;
						
						var cyar=this.cyararr[this.curCyarIdx];
		  
						var docWid=$(document.body).width();
						var docHit=	 $(document).height();		
											
						console.log("--docWid wid:"+docWid);
					
					
						 
						
						
						var imgStr='<img src="i.gif" style="position:absolute; left:0; width:100px;height:100px;display:none;"  class="cyar_tag" />';
					 //	imgStr=imgStr.replace("@w@",rdmWid);
						imgStr=imgStr.replace("@cyar@",cyar);
					//	 console.log("--imgStr:"+imgStr);
						var $h1=$(imgStr); 	
					$("body").append($h1);	
					 $h1.load(function(){  
								var w =  $h1.width();  
								var h = $h1.height();  
								
								var imgWid=$($h1).width();
							console.log("--imgWid wid:"+imgWid);
							 var maxTop=docHit-h;
							 var minTop=166;
							//imgWid;//maxWid=800;
						//	var rdmWid= Math.floor(Math.random()*(maxWid+1));
					
						
							var rdmWid=randNum(minTop,maxTop);
							console.log("--rdm :"+rdmWid);
							$h1.css("top",rdmWid+"px").show();
						}	);				
							
							
					
						//   this.addChild(sushi,5);
						// $(".sushi_tag_5kwi").css("top","0");
						//$(".sushi_tag_5kwi")
						
						
						//down move
						// var dorpAction = cc.MoveTo.create(4, cc.p(sushi.x,-30));
						//	sushi.runAction(dorpAction);
						$($h1).animate({left:"800px"},10000);
	 
	 					
						
						//gc
						 
							window.setTimeout(function(){
								 $($h1).remove();
								
							},10000);
							
							
							//add click
							 $h1.on( "click", function() {
								 
									this.expFun($h1);//blood
								   playAudio();
								   subCyar=cyar;
								//   alert(subCyar);
								   
									// btn_ev();
								
									
									 }.bind(this) ); 
									 
								 
	 
			 }  //end add fun
	   
	   
	   };
 //  PlayLayer.ctor();
	
	 function  playAudio()
 {
	 
	  var aa = $("#audio1")[0];  
								   try{
								   aa.currentTime=0;
								   }catch(e){
									   console.log("---cur time not eff,load use");
									   aa.load();
									   }
									aa.play(); 
	 
 }				
 

page_load();
</script>

</body>
</html>
